Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all writeable properties to TypeProperties cache #159

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

alamb3142
Copy link

This catches any writeable property, including internal properties that were previously ignored.

This caught me out because my I created my table models as internal models (which I think is the default now if you're working in VS 2022?) to prevent dependant projects from trying to use them, and only after debugging Dapper.Contrib locally did I realise that only the public properties were being mapped to column names.

For reference here's the error message I was seeing when calling InsertAsync on my internal model:
image

And the SQL it generated to cause this was:
INSERT INTO dbo.my_table () values (); SELECT SCOPE_IDENTITY() id

This catches any writeable property, including internal properties that were previously ignored
@alamb3142
Copy link
Author

Please let me know if there's a reason why public properties only are better. I'd also be happy to add in a check here that throws when 0 properties are found and some tests around this behaviour

Binding flags filter still pulls back private properties, this prevents those properties from being mapped
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant